<?php

class blocks extends MX_Controller
{
    public function blocks()
    {
        parent::__construct();
        $this->load->helper('text');
    }
    
    public function header()
    {
        return $this->load->view('blocks/header', array());
    }
    
    public function footer()
    {
        $this->load->model('pages_model');
        $pagemodel = new Pages_Model();
        $data = $pagemodel->getPagesById(1);
        if ($data) {
            $content = $data->contents;
        } else {
            $content = '';
        }
        return $this->load->view('blocks/footer', array('content' => $content));
    }
    
    public function nav()
    {
        $this->load->model('Relax_Categories_Model');
        $relax = new Relax_Categories_Model();
        $nav = $relax->getNav();
        return $this->load->view('blocks/nav', array('nav' => $nav));
    } 
    
    public function abweek()
    {
        $this->load->model('Relax_Articles_Model');
        $relax = new Relax_Articles_Model();
        $result = $relax->articleByWeek();
        return $this->load->view('blocks/abweek', array('result' => $result));
    }
    
    public function dovui()
    {
        $this->load->model('Relax_Articles_Model');
        $relax = new Relax_Articles_Model();
        $result_hit = $relax->articleByCatetory(1, 1);
        $result_new = $relax->articleByCatetory(1, 2);
       
        return $this->load->view('blocks/dovui', array(
            'result_hit' => $result_hit, 
            'result_new' => $result_new
            ));
    }
    
    public function truyentranh()
    {
        $this->load->model('Relax_Articles_Model');
        $relax = new Relax_Articles_Model();
        $result_hit = $relax->articleByCatetory(5, 1);
        $result_new = $relax->articleByCatetory(5, 2);
       
        return $this->load->view('blocks/truyentranh', array(
            'result_hit' => $result_hit, 
            'result_new' => $result_new
            ));
    }
    public function truyencuoi()
    {
        $this->load->model('Relax_Articles_Model');
        $relax = new Relax_Articles_Model();
        $result_hit = $relax->articleByCatetory(2, 1);
        $result_new = $relax->articleByCatetory(2, 2);
       
        return $this->load->view('blocks/truyencuoi', array(
            'result_hit' => $result_hit, 
            'result_new' => $result_new
            ));
    }
    
    public function wiki()
    {
        $this->load->model('Relax_Articles_Model');
        $relax = new Relax_Articles_Model();
        $result_hit = $relax->articleByCatetory(4, 1);
        $result_new = $relax->articleByCatetory(4, 2);
       
        return $this->load->view('blocks/wiki', array(
            'result_hit' => $result_hit, 
            'result_new' => $result_new
            ));
    }
    public function tho()
    {
        $this->load->model('Relax_Articles_Model');
        $relax = new Relax_Articles_Model();
        $result_hit = $relax->articleByCatetory(7, 1);
        $result_new = $relax->articleByCatetory(7, 2);
       
        return $this->load->view('blocks/tho', array(
            'result_hit' => $result_hit, 
            'result_new' => $result_new
            ));
    }
    public function anhvui()
    {
        $this->load->model('Relax_Articles_Model');
        $relax = new Relax_Articles_Model();
        $result_new = $relax->articleByCatetory(3, 2);
       
        return $this->load->view('blocks/anhvui', array(
            'result_new' => $result_new
            ));
    }
}